<template>
  <div class="aa-container">
    <div class="flex-row ">
      <div class="material-textfield green form-left" :class="{'validate-err': errors.has('engineeringName')}">
        <input type="text" required v-model="projectinfo.engineeringName" v-validate="'required|max:40'" name="engineeringName"/>
        <label data-content="工程项目名称*"></label>
      </div><!--
    --><div class="form-right flex-row">
        <label class="ewai">是否同意调整奖项*</label>
        <el-radio v-model="projectinfo.isRevise" label="YES" style="padding-top: 8px;">是</el-radio>
        <el-radio v-model="projectinfo.isRevise" label="NO" style="padding-top: 8px;">否</el-radio>
      </div>
    </div>
    <!-- <div class="flex-row">
      <div class="material-textfield green form-left" :class="{'validate-err': errors.has('applyAward')}">
        <input type="text" required v-model="projectinfo.applyAward " v-validate="'required|max:40'" name="applyAward"/>
        <label data-content="申报奖项*">申报奖项*</label>
      </div>
      <div class="material-textfield green form-right" :class="{'validate-err': errors.has('resultType')}">
        <input type="text" required v-model="projectinfo.resultType" v-validate="'required|max:25'" name="resultType"/>
        <label data-content="成果类型*">成果类型*</label>
      </div>
    </div> -->
    <div class="flex-row ">
      <div class="material-textfield green form-left" :class="{'validate-err': errors.has('applyAward')}">
        <el-select v-model="projectinfo.applyAward" placeholder="" class="width-full" v-validate="'required'" name="applyAward">
          <el-option
            v-for="item in optionsAward"
            :filterable="true"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <label data-content="申报奖项*"></label>
      </div>
      <div class="material-textfield green form-right" :class="{'validate-err': errors.has('resultType')}">
        <el-select v-model="projectinfo.resultType" placeholder="" class="width-full" v-validate="'required'" name="resultType">
          <el-option
            v-for="item in optionsType"
            :filterable="true"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
        <label data-content="成果类型*"></label>
      </div>
    </div>

    <div class="flex-row">
      <div class="material-textfield green form-left" :class="{'validate-err': errors.has('startTime')}">
        <el-date-picker
         v-validate="'required'" name="startTime"
         class="width-full date-icon-right"
         type="date"
         v-model="projectinfo.startTime"
         :pickerOptions="startday"
         format="yyyy-MM-dd"
         value-format="yyyy-MM-dd"
         placeholder="">
       </el-date-picker>
        <label data-content="实施时间*"></label>
      </div><!--
    --><div class="material-textfield green form-right" :class="{'validate-err': errors.has('endTime')}">
        <el-date-picker
         v-validate="'required'" name="endTime"
         class="width-full date-icon-right"
         type="date"
         format="yyyy-MM-dd"
         value-format="yyyy-MM-dd"
         v-model="projectinfo.endTime"
         :pickerOptions="endday"
         placeholder="">
        </el-date-picker>
        <label data-content="截止时间*"></label>
      </div>
    </div>
    <div class="flex-row">
      <div class="material-textfield green form-left" :class="{'validate-err': errors.has('totalAmount')}">
        <input type="text" required v-model="projectinfo.totalAmount" v-validate="'required|number|max_value:99999999'" name="totalAmount"/>
        <label data-content="项目产值总额*"></label>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    title: '项目信息',
    name: 'project-info',
    data () {
      return {
        projectinfo: {},
        optionsAward: [
          { label: '金奖', value: 'GOLD' },
          { label: '银奖', value: 'SILVER' },
          { label: '铜奖', value: 'BRONZD' }
        ],
        optionsType: [
          { label: '大地测量', value: 'DDCL' },
          { label: '测绘航空摄影', value: 'CHHKSY' },
          { label: '摄影测量与遥感', value: 'SYCLYYG' },
          { label: '工程测量', value: 'GCCL' },
          { label: '地籍测绘', value: 'DJCH' },
          { label: '房产测绘', value: 'FCCH' },
          { label: '行政区域界线测绘', value: 'XZQYJXCH' },
          { label: '地理信息系统工程', value: 'DLXXXTGC' },
          { label: '地图编制', value: 'DTBZ' },
          { label: '导航电子地图制作', value: 'DHDZDTZZ' },
          { label: '海洋测绘', value: 'HYCH' },
          { label: '互联网地图服务', value: 'HLWDTFW' },
          { label: '其他', value: 'QT' },
        ],
        startday: {
          disabledDate(time) {
            return time.getTime() > Date.now() - 8.64e6
          }
        },
        endday: {
          disabledDate: (time) => {
            if (!this.projectinfo.startTime) {
              return true
            }
            return (time.getTime() >  Date.now() - 8.64e6) || (time.getTime() < new Date(this.projectinfo.startTime).getTime())
          }
        }
      }
    },
    props: {
      data: {}
    },
    mounted () {
      this.projectinfo = Object.assign({}, this.data)
    },
    methods: {
      validate () {
        return this.$validator.validateAll()
      }
    },
    watch: {
      'projectinfo': {
        handler: function (val, oldVal) {
          this.$emit('update:data', this.projectinfo)
        },
        deep: true
      }
    }
  }
</script>
